<?php
//資料庫設定
//資料庫位置
$db_server = "localhost";
//資料庫名稱
$db_name = "test";
//資料庫管理者帳號
$db_user = "root";
//資料庫管理者密碼
$db_passwd = "df2009jk";

//對資料庫連線
if(!@mysql_connect($db_server, $db_user, $db_passwd))
        die("無法對資料庫連線");

//資料庫連線採UTF8
mysql_query("SET NAMES utf8");

//選擇資料庫
if(!@mysql_select_db($db_name))
        die("無法使用資料庫");
?>  
<?php session_start(); ?>
<?php
//連接資料庫
//只要此頁面上有用到連接MySQL就要include它
include("mysql_connect.inc.php");
$Name = $_GET['Name'];
$ID = $_GET['ID'];
$Strength = $_GET['Strength'];
$MilitaryTitle = $_GET['MilitaryTitle'];
$MilitaryRank = $_GET['MilitaryRank'];
$MilitaryEXP = $_GET['MilitaryEXP'];
$Influence = $_GET['Influence'];

$sql = "SELECT * FROM erep where ID = '$ID'";
$result = mysql_query($sql);
$row = @mysql_fetch_row($result);
if($row[0] != NULL) {
	mysql_query("UPDATE erep SET Strength = '$Strength', MilitaryTitle = '$MilitaryTitle', MilitaryRank = '$MilitaryRank', MilitaryEXP = '$MilitaryEXP', Influence = '$Influence' WHERE ID = '$ID'");
}
else {
	mysql_query("INSERT erep SET Name = '$Name', ID = '$ID', Strength = '$Strength', MilitaryTitle = '$MilitaryTitle', MilitaryRank = '$MilitaryRank', MilitaryEXP = '$MilitaryEXP', Influence = '$Influence'");
}
?>

